package simtester.server



import grails.test.mixin.*
import org.junit.*

/**
 * See the API for {@link grails.test.mixin.domain.DomainClassUnitTestMixin} for usage instructions
 */
@TestFor(Iteration)
class IterationTests {

    @Test
    void createIterationSuccessfully() {
        def iter = new Iteration(user: 1, num: 3, status: 'running', startDate: new Date())
        assert iter.validate()
    }
    
    @Test
    void createIterationWithoutRequiredFields() {
        def tr = new Iteration()
        assert !tr.validate()
        tr.errors.errorCount == 4
        assert 'nullable' in tr.errors['user'].codes
        assert 'nullable' in tr.errors['num'].codes
        assert 'nullable' in tr.errors['status'].codes
        assert 'nullable' in tr.errors['startDate'].codes
    }
}
